﻿namespace Daemon.Data.Substructure.Framework
{
	using System;
	using System.Collections.Generic;
	using Newtonsoft.Json;
	using Newtonsoft.Json.Converters;

	/// <summary>
	/// Contains FilterItems and nested FilterSets.
	/// </summary>
	[Serializable]
	public class FilterSet
	{
		/// <summary>
		/// Set of simple conditions.
		/// </summary>
		public List<FilterItem> FilterItems { get; set; }

		/// <summary>
		/// Set of complex conditions consist of nested FilterSet.
		/// </summary>
		public List<FilterSet> FilterSets { get; set; }

		/// <summary>
		/// The flag of is reduce records filterSet applys to all child FilterItems and FilterSets of current FilterSet.
		/// </summary>
		public bool IsReduceRecordsFilterSet { get; set; }

		/// <summary>
		/// The flag of whether convert to raw where clause.
		/// </summary>
		public bool IsConvertToRawWhereClause { get; set; } = true;

		/// <summary>
		/// The flag of whether convert datetime value to local format.
		/// </summary>
		public bool IsConvertDateTimeToLocalFormat { get; set; }

		/// <summary>
		/// The id used to filter form data
		/// </summary>
		public int? UDGridID { get; set; }

		/// <summary>
		/// The Logical Operator applys to all child FilterItems and FilterSets of current FilterSet.
		/// </summary>
		[JsonConverter(typeof(StringEnumConverter))]
		public LogicalOperator LogicalOperator { get; set; }
	}
}
